# Contributor: Runar Tenfjord < runar dot tenfjord at gmail dot com >

_realname=six
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-$_realname" "${MINGW_PACKAGE_PREFIX}-python3-$_realname")
pkgver=1.11.0
pkgrel=1
pkgdesc="Python 2 and 3 compatibility utilities (mingw-w64)"
arch=('any')
url="https://pypi.python.org/pypi/six/"
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python3")
source=(https://pypi.io/packages/source/${_realname:0:1}/${_realname}/${_realname}-${pkgver}.tar.gz)
sha256sums=('70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9')

prepare() {
  cd "${srcdir}"
  cp -r six-$pkgver python2-six-${pkgver}
  cp -r six-$pkgver python3-six-${pkgver}
}

check() {
  cd ${srcdir}/python2-six-${pkgver}
  ${MINGW_PREFIX}/bin/python2 setup.py check
  cd ${srcdir}/python3-six-${pkgver}
  ${MINGW_PREFIX}/bin/python3 setup.py check
}

package_python3-six() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd ${srcdir}/python3-six-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
  --root "${pkgdir}" --optimize=1

  install -Dm644 "${srcdir}/six-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-six() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd ${srcdir}/python2-six-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
  --root "${pkgdir}" --optimize=1

  install -Dm644 "${srcdir}/six-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-six() {
  package_python2-six
}

package_mingw-w64-i686-python3-six() {
  package_python3-six
}

package_mingw-w64-x86_64-python2-six() {
  package_python2-six
}

package_mingw-w64-x86_64-python3-six() {
  package_python3-six
}
